--[[/**
-- * 
 * 伤害
 *
-- */]]

---@class BuffEffect603100 : BaseBuffEffect
BuffEffect603100 = ClientFight.CreateClass("BuffEffect603100", ClientFight.BaseBuffEffect)
local t = BuffEffect603100

---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
    local parameters = {...};
    local buffEffectValue = buff.buffBean.f_BuffEffectValue;
    local baseRatio = buffEffectValue[4];
    local maxHp = FighterAttributeManager.getFightAttr(buff.source, FighterAttributeEnum.HP);
    local addHp = buff.target.parametersByObject[BuffEffect607100.BuffEffect607100_ADD_HP] or 0;

    baseRatio = baseRatio + (Utils.fromRatio(addHp / maxHp) / buffEffectValue[5] * buffEffectValue[6]);
    local random = 1 + buff.source.fight.random(Global.TEN_THOUSANDTH);
    if (random > baseRatio) then
        return IBuffEffect.FAIL;
    end
    local f_BuffEffectValue = buff.buffBean.f_BuffEffectValue;
    local skillId = f_BuffEffectValue[1];
    local logRatio = baseRatio;
    SkillRoleMgr.savePathFile("[" .. fight.frame .. "][EFFECT]Fighter " .. buff.target.fighterId .. " Buff"
            .. buff.modelId .. " 触发释放技能：" .. skillId .. " 攻速增加的概率: " .. (logRatio - buffEffectValue[4]) .. "  基础概率: " .. logRatio);
    local targetType = f_BuffEffectValue[2];
    local fighterType = f_BuffEffectValue[3];
    local target = nil;
    local fighter = nil
    if (targetType == 1) then
        target = buff.source;
    elseif (targetType == 2) then
        target = buff.target;
    elseif (targetType == 3) then
        target = parameters[1];
    end
    if (fighterType == 1) then
        fighter = buff.target;
    else
        fighter = buff.source;
    end
    t:triggerSkill(fight, fighter, target, skillId);

    return ClientFight.BaseBuffEffect.action(self, fight, buff, ...);
end

t.New()